<?php if($claimView){ ?>
<div class="claims index">
	<h2><?php __('Claims');?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('id');?></th>
			<th><?php echo $this->Paginator->sort('user_id');?></th>
			<th><?php echo $this->Paginator->sort('listing_id');?></th>
			<th><?php echo $this->Paginator->sort('name');?></th>
			<th><?php echo $this->Paginator->sort('telephone');?></th>
			<th><?php echo $this->Paginator->sort('comment');?></th>
			<th><?php echo $this->Paginator->sort('created');?></th>
			<th><?php echo $this->Paginator->sort('modified');?></th>
			<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($claims as $claim):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $claim['Claim']['id']; ?>&nbsp;</td>
		<td>
			<?php echo $this->Html->link($claim['User']['username'], array('controller' => 'users', 'action' => 'view', $claim['User']['id'])); ?>
		</td>
		<td>
			<?php echo $claim['Listing']['title']; ?>
		</td>
		<td><?php echo $claim['Claim']['name']; ?>&nbsp;</td>
		<td><?php echo $claim['Claim']['telephone']; ?>&nbsp;</td>
		<td><?php echo $claim['Claim']['comment']; ?>&nbsp;</td>
		<td><?php echo $claim['Claim']['created']; ?>&nbsp;</td>
		<td><?php echo $claim['Claim']['modified']; ?>&nbsp;</td>
		<td class="actions">
<?php			
			if($claim['Claim']['status'] == 1){
					echo $this->Html->link('Disapprove', array('admin' => false, 'plugin' => null, 'controller' => 'listings', 'action' => 'submit', $claim['Claim']['id'], 'disapprove'));
						
			} else {
						echo $this->Html->link('Approve Permission', array('admin' => false, 'plugin' => null, 'controller' => 'listings', 'action' => 'submit', $claim['Claim']['id'], 'approve'));

			}  ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
<?php } else { ?>
<?php
	$this->Paginator->options(array('url' => array('admin' => true, 'plugin' => null, 'controller' => 'listings', 'action' => 'index_all')));
?>
<div class="listings index">
	<h2><?php echo 'Сайт - листинги'; ?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
		<th>
		<?php
			echo $this->Paginator->sort(
				'ID',
				'id'
			);
		?>
		</th>
		<th>
		<?php
			echo $this->Paginator->sort(
				'Активиран',
				'is_active'
			);
		?>
		</th>
		<th>
		<?php
			echo $this->Paginator->sort(
				'Заглавие',
				'title'
			);
		?>
		</th>
		<th class="actions"><?php echo 'Действия'; ?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($listings as $listing) {
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
		<tr<?php echo $class;?>>
			<td>
				<?php echo $listing['Listing']['id']; ?>
			</td>
			<td>
				<?php
				if($listing['Listing']['is_active']) {
					echo '<span style="color: green">'.'да'.'</span>';
				} else {
					echo '<span style="color: red">'.'не'.'</span>';
				}
				?>
			</td>
			<td>
				<?php echo htmlspecialchars($listing['Listing']['title']); ?>
			</td>
			<td class="actions">
				<?php echo $this->Html->link('Редактиране', array('admin' => true, 'plugin' => null, 'controller' => 'listings', 'action' => 'edit', $listing['Listing']['id'])); ?>
				<?php echo $this->Html->link('Изтриване', array('admin' => true, 'plugin' => null, 'controller' => 'listings', 'action' => 'delete', $listing['Listing']['id']), null, sprintf('Сигурни ли сте, че искате да изтриете # %s?', $listing['Listing']['id'])); ?>
				<?php
					if(trim($listing['Listing']['claim_by_users']) != ''){
				echo $this->Html->link('View User who Claim', array('admin' => true, 'plugin' => null, 'controller' => 'users', 'action' => 'index', $listing['Listing']['id']));
				 }
				  ?>
			</td>
		</tr>
	<?php } ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => 'Страницa %page% от %pages%, показваща %current% записа от %count% общо, започваща от запис %start%, свършваща на запис %end%'
	));
	?></p>
	<div class="paging">
		<?php echo $this->Paginator->prev('<< '.'предишна', array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
	 |
		<?php echo $this->Paginator->next('следваща'.' >>', array(), null, array('class'=>'disabled'));?>
	</div>
</div>
<div class="actions">
	<h3><?php echo 'Действия:'; ?></h3>
	<ul>
		<li><?php echo $this->Html->link('Всички листинги', array('admin' => true, 'plugin' => null, 'controller' => 'listings', 'action' => 'index_all'));?></li>
		<li><?php echo $this->Html->link('Неодобрени листинги', array('admin' => true, 'plugin' => null, 'controller' => 'listings', 'action' => 'index_new'));?></li>
	</ul>
</div>
<?php } ?>